<!-- @format -->

<!-- 仓库不同业务价卡配置 2b / 2c -->
<template>
	<div>
		<el-form>
			<el-row>
				<!-- 成本计费币种 -->
				<!--      <el-col :span="1">-->
				<!--        <el-form-item label="成本计费币种">-->
				<!--          <fms-currency-choose v-model="formValue.costCurrency"  style="width: 100%;"></fms-currency-choose>-->
				<!--        </el-form-item>-->
				<!--      </el-col>-->

				<el-col :span="1">
					<!-- 销售计费币种 -->
					<el-form-item :label="$tt('label_pms_sell_price')">
						<fms-currency-choose v-model="formValue.currencyType" style="width: 100%;"></fms-currency-choose>
					</el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="3">
					<el-form-item label="">
						<!-- 开启仓租服务 -->
						<el-switch v-model="formValue.openRent" :active-text="$tt('label_pms_open_tenant_service')" inactive-text=""> </el-switch>

						<!--             开启旺季附加费 -->
						<!--            <el-switch-->
						<!--              style="margin-left: 20px;"-->
						<!--              v-model="formValue.openAdditional"-->
						<!--              active-text="开启旺季附加费"-->
						<!--              inactive-text="">-->
						<!--            </el-switch>-->

						<!-- 仓租时间段配置 -->
						<el-button
							v-if="formValue.openRent"
							type="text"
							style="margin-left: 20px;"
							@click="
								dialogFormVisible = true;
								resetWeightArray('RENT');
							"
							>{{ $tt('label_pms_tenant_cfg') }}
						</el-button>

						<!-- 旺季时间段配置 -->
						<!--            <el-button v-if="formValue.openAdditional" type="text" style="margin-left: 20px;"-->
						<!--                       @click="additionalVisible = true">{{ $tt('label_pms_host_time_cfg') }}-->
						<!--            </el-button>-->

						<!-- 旺季时间段配置 -->
						<!--  <el-button>旺季时间段配置</el-button>-->
					</el-form-item>
				</el-col>
			</el-row>

			<el-row v-if="formValue.openRent">
				<el-col :span="1">
					<el-form-item label="出库时效">
						<el-input v-model="formValue.outboundTimeOut">
							<template slot="append">小时</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="2">
					<el-form-item label="" labelWidth="0">
						<span style="color: #666; margin-left: 20px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>出库单下发后，如果超过该时间还没有出库，这部分库存不计算仓租</span>
					</el-form-item>
				</el-col>
			</el-row>
			<!-- 临时存储区收费 -->
			<!--      <el-col :span="1">-->
			<!--        <el-form-item label="临时存储区收费">-->
			<!--          <el-input v-model="formValue.tmpLocationPrice">-->
			<!--            <template slot="append">{{  showPriceUnitDesc( formValue.currencyType, '元/立方米/天') }}&nbsp;</template>-->
			<!--          </el-input>-->
			<!--        </el-form-item>-->
			<!--      </el-col>-->

			<!--      <el-col >-->
			<!--        <el-form-item label="" labelWidth="0">-->
			<!--          <span style="color: #666; margin-left: 20px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>B2B装卸费/仓储费/临时存放费</span>-->
			<!--        </el-form-item>-->
			<!--      </el-col>-->
			<!--    </el-row>-->
			<!--    -->
			<el-row v-if="formValue.openRent">
				<el-col :span="3" style="width: 100%;">
					<!-- 仓租费用 -->
					<el-form-item :label="$tt('label_pms_tenant_price')">
						<span style="color: #666; margin-left: 10px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>当仓租总费用的低于最低收费，按照最低收费收费</span>

						<el-table :data="formValue.houseRentPrice" border :key="'houseRentPrice' + randomId">
							<!--库龄范围（天） -->
							<el-table-column prop="period" :label="$tt('label_pms_storage_age')" min-width="100" align="center"></el-table-column>
							<!-- 商品分类 -->
							<el-table-column prop="customSkuSpecName" label="商品分类" min-width="100" align="center"></el-table-column>

							<!-- 单位 -->
							<el-table-column prop="unit" :label="$tt('label_pms_storate_unit')" min-width="100" align="center">
								<template slot-scope="scope">
									{{ $tt('PmsPriceUnitEnum__YUAN_CBM_DAY') }}
								</template>
							</el-table-column>
							<!-- 销售单价 -->
							<el-table-column prop="price" :label="$tt('label_pms_sell_money')" min-width="100" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.price"></el-input>
								</template>
							</el-table-column>
							<!-- 仓租时间段最低收费 -->
							<el-table-column prop="payAmount" label="最低收费" width="140" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.minPrice" placeholder="请输入正数" oninput="value=value.replace(/[^\d.]/g, '')"> </el-input>
								</template>
							</el-table-column>

							<!-- 旺季附加费 -->
							<el-table-column prop="additionalPrice" :label="$tt('label_pms_host_add_price')" min-width="100" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.additionalPrice">
										<!--                  <template slot="append">%</template>-->
									</el-input>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="1">
					<!-- 重货起始值 -->
					<el-form-item :label="$tt('label_pms_heavy_weight')">
						<el-input v-model="formValue.heavyWeight">
							<template slot="append">{{ productGlobalConfig.weightUnit }}</template>
						</el-input>
					</el-form-item>
				</el-col>
				<el-col :span="2">
					<el-form-item label="" labelWidth="0">
						<!-- 出库时订单重量大于该值， 会按 "出库（重货）" 进行计费 -->
						<span style="color: #666; margin-left: 20px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>{{ $tt('label_pms_heavy_weight_tip') }}</span>
					</el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="3" style="width: 100%;">
					<!-- 标准服务项 -->
					<el-form-item :label="$tt('label_pms_standard_service')">
						<!-- 标准服务项是仓库作业时，相应单据创建后，仓库操作人员一定会执行的操作 -->
						<span style="color: #666; margin-left: 10px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>{{ $tt('label_pms_warehouse_standard_service') }}</span>

						<el-table :data="formValue.standardServicePrice" style="  margin-top: 10px; " border :key="'standardServicePrice' + randomId">
							<!--服务项名称 -->
							<el-table-column prop="serviceCode" :label="$tt('label_pms_service_name')" min-width="180" align="center">
								<template slot-scope="scope">
									<div style="text-align: left;">{{ $tt('PmsServiceCodeEnum__' + scope.row.serviceCode) }}</div>
								</template>
							</el-table-column>

							<!-- 是否收费 -->
							<el-table-column prop="needCharge" :label="$tt('label_pms_need_price')" min-width="90" align="center">
								<template slot-scope="scope">
									<el-switch v-model="scope.row.needCharge" active-text="" inactive-text=""> </el-switch>
								</template>
							</el-table-column>

							<!--收费粒度 -->
							<el-table-column prop="serviceCode" label="计费粒度" min-width="180" align="center">
								<template slot-scope="scope">
									<ex_super_input v-model="scope.row.priceGranularity" type="select" enum="PmsPriceGranularityEnum" style="width: 100%;"> </ex_super_input>
								</template>
							</el-table-column>

							<!-- 收费方式 -->
							<el-table-column prop="chargeType" :label="$tt('label_pms_charge_type')" min-width="130" align="center">
								<template slot-scope="scope">
									<ex_super_input
										v-model="scope.row.chargeType"
										type="select"
										enum="PmsChargeTypeEnum"
										:disabled="!scope.row.needCharge"
										:clearable="false"
										:listHandler="(list) => choosePriceType(list, scope.row)"
									></ex_super_input>
								</template>
							</el-table-column>

							<!-- xxxx -->
							<!--            <el-table-column prop="costPrice" :label="成本单价" width="206" align="center">-->
							<!--              <template slot-scope="scope">-->
							<!--                <div style="display: flex; align-items: center; padding-left: 10px;">-->
							<!--                  <el-input v-model="scope.row.costPrice" style="width: 80px;" ></el-input>-->
							<!--                  <div style="padding-left: 10px;">-->
							<!--                    {{  showPriceUnitDesc( formValue.costCurrency, scope.row.chargeType ? $tt('PmsPriceUnitEnum__' + priceUnitMap[ scope.row.chargeType ]) : '') }}&nbsp;-->
							<!--                  </div>-->
							<!--                </div>-->
							<!--              </template>-->
							<!--            </el-table-column>-->

							<!-- 销售单价 -->
							<el-table-column prop="payAmount" :label="$tt('label_pms_sell_money')" min-width="420" align="center">
								<template slot-scope="scope">
									<div v-if="scope.row.chargeType !== 'EXPRESSION'" style="display: flex; align-items: center; padding-left: 10px;">
										<el-input v-model="scope.row.price" style="width: 80px;" :disabled="!scope.row.needCharge" v-if="!(scope.row.chargeType === 'WEIGHT_RANGE')"></el-input>
										<div style="padding-left: 10px;" v-if="!(scope.row.chargeType === 'WEIGHT_RANGE')">
											{{ showPriceUnitDesc(formValue.currencyType, scope.row.chargeType ? $tt('PmsPriceUnitEnum__' + priceUnitMap[scope.row.chargeType]) : '', scope.row.chargeType) }}&nbsp;
										</div>
										<div v-if="scope.row.showMax && scope.row.chargeType !== 'WEIGHT_RANGE'" style="display: flex; align-items: center;">
											<!-- 上限 -->
											，{{ $tt('label_max_limit') }}
											<el-input v-model="scope.row.maxPrice" style="width: 80px; margin-left: 8px;"></el-input>
											<div style="padding-left: 10px;">{{ showPriceUnitDesc(formValue.currencyType) }}&nbsp;</div>
										</div>
										<div style="display: flex;padding-left: 10px;">
											<el-button
												v-if="scope.row.chargeType === 'WEIGHT_RANGE'"
												@click="
													weightRangeShow(scope.row, scope.$index, 'stand');
													resetWeightArray('WEIGHT_RANGE');
												"
												type="text"
												size="medium"
											>
												<!-- 重量段配置  体积段配置 -->
												{{ $tt('label_pms_weight_range_cfg') }}
											</el-button>
										</div>
									</div>
									<div v-if="scope.row.chargeType === 'EXPRESSION'" style="display: flex; align-items: center; padding-left: 10px;">
										<el-button type="text" @click="showExpressionDialog(scope.row, scope.$index, 'stand')">表达式配置</el-button>
									</div>
								</template>
							</el-table-column>
							<!-- 旺季附加费 -->
							<el-table-column v-if="formValue.openAdditional" prop="payAmount" :label="$tt('label_pms_host_add_price')" min-width="140" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.additionalPrice">
										<template slot="append">%</template>
									</el-input>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>
			</el-row>

			<el-row>
				<el-col :span="3" style="width: 100%;">
					<!-- 增值服务项 -->
					<el-form-item :label="$tt('label_pms_add_service')">
						<!-- 附加服务项是仓库作业时可选的操作 -->
						<span style="color: #666; margin-left: 10px; "><i class="el-icon-warning" style="  margin-right: 6px; "></i>{{ $tt('label_pms_add_service_tip') }}</span>

						<el-table :data="formValue.additionalServicePrice" style=" margin-top: 10px; " border>
							<!-- 服务项名称 -->
							<el-table-column prop="serviceCode" :label="$tt('label_pms_service_name')" min-width="180" align="center">
								<template slot-scope="scope">
									<div style="text-align: left;">{{ $tt('PmsServiceCodeEnum__' + scope.row.serviceCode) }}</div>
								</template>
							</el-table-column>

							<!-- 是否收费 -->
							<el-table-column prop="needCharge" :label="$tt('label_pms_need_price')" min-width="90" align="center">
								<template slot-scope="scope">
									<el-switch v-model="scope.row.needCharge" active-text="" inactive-text=""> </el-switch>
								</template>
							</el-table-column>

							<!--收费粒度 -->
							<el-table-column prop="serviceCode" label="计费粒度" min-width="180" align="center">
								<template slot-scope="scope">
									<ex_super_input v-model="scope.row.priceGranularity" type="select" enum="PmsPriceGranularityEnum" style="width: 100%;"> </ex_super_input>
								</template>
							</el-table-column>

							<!-- 收费方式 -->
							<el-table-column prop="chargeType" :label="$tt('label_pms_charge_type')" min-width="130" align="center">
								<template slot-scope="scope">
									<ex_super_input
										v-model="scope.row.chargeType"
										type="select"
										enum="PmsChargeTypeEnum"
										:disabled="!scope.row.needCharge"
										:clearable="false"
										:listHandler="(list) => choosePriceType(list, scope.row)"
									></ex_super_input>
								</template>
							</el-table-column>

							<!--            <el-table-column prop="costPrice" label="成本单价" width="206" align="center">-->
							<!--              <template slot-scope="scope">-->
							<!--                <div style="display: flex; align-items: center; padding-left: 10px;">-->
							<!--                  <el-input v-model="scope.row.costPrice" style="width: 80px;" ></el-input>-->
							<!--                  <div style="padding-left: 10px;">-->
							<!--                    {{  showPriceUnitDesc( formValue.costCurrency, scope.row.chargeType ? $tt('PmsPriceUnitEnum__' + priceUnitMap[ scope.row.chargeType ]) : '') }}&nbsp;-->
							<!--                  </div>-->
							<!--                </div>-->
							<!--              </template>-->
							<!--            </el-table-column>-->

							<!-- 销售单价 -->
							<el-table-column prop="payAmount" :label="$tt('label_pms_sell_money')" min-width="420" align="center">
								<template slot-scope="scope">
									<div v-if="scope.row.chargeType !== 'EXPRESSION'" style="display: flex; align-items: center; padding-left: 10px;">
										<el-input v-model="scope.row.price" style="width: 80px;" :disabled="!scope.row.needCharge" v-if="!(scope.row.chargeType === 'WEIGHT_RANGE')"></el-input>
										<div style="padding-left: 10px;" v-if="!(scope.row.chargeType === 'WEIGHT_RANGE')">
											{{ showPriceUnitDesc(formValue.currencyType, scope.row.chargeType ? $tt('PmsPriceUnitEnum__' + priceUnitMap[scope.row.chargeType]) : '', scope.row.chargeType) }}&nbsp;
										</div>
										<div v-if="scope.row.showMax && scope.row.chargeType !== 'WEIGHT_RANGE'" style="display: flex; align-items: center;">
											<!-- 上限 -->
											，{{ $tt('label_max_limit') }}
											<el-input v-model="scope.row.maxPrice" style="width: 80px; margin-left: 8px;"></el-input>
											<div style="padding-left: 10px;">{{ showPriceUnitDesc(formValue.currencyType) }}&nbsp;</div>
										</div>
										<div style="display: flex;padding-left: 10px;">
											<el-button
												v-if="scope.row.chargeType === 'WEIGHT_RANGE'"
												@click="
													weightRangeShow(scope.row, scope.$index, 'additional');
													resetWeightArray('WEIGHT_RANGE');
												"
												type="text"
												size="medium"
											>
												<!-- 重量段配置  体积段配置 -->
												{{ $tt('label_pms_weight_range_cfg') }}
											</el-button>
										</div>
									</div>
									<div v-if="scope.row.chargeType === 'EXPRESSION'" style="display: flex; align-items: center; padding-left: 10px;">
										<el-button type="text" @click="showExpressionDialog(scope.row, scope.$index, 'additional')">表达式配置</el-button>
									</div>
								</template>
							</el-table-column>

							<!-- 旺季附加费 -->
							<el-table-column v-if="formValue.openAdditional" prop="payAmount" :label="$tt('label_pms_host_add_price')" min-width="140" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.additionalPrice">
										<!--                  <template slot="append">%</template>-->
									</el-input>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>

		<!-- 表达式弹窗 -->
		<expression-edit-dialog ref="expression" @save="saveExpression"></expression-edit-dialog>

		<!-- 仓租时间段配置 -->
		<el-dialog :title="$tt('label_pms_tenant_time_cfg')" :visible.sync="dialogFormVisible" width="1400px">
			<ex_header_spiler title="时间区间配置"></ex_header_spiler>
			<el-form inline>
				<!-- 生成方式 -->
				<el-form-item :label="$tt('label_pms_generate_type')" labelWidth="90px">
					<el-radio-group v-model="weightForm.genType">
						<!-- 按步长 -->
						<el-radio-button label="byStep">{{ $tt('label_pms_by_step') }}</el-radio-button>
						<!-- 按分段数量 -->
						<el-radio-button label="byNumber">{{ $tt('label_pms_by_split_num') }}</el-radio-button>
					</el-radio-group>
				</el-form-item>

				<!-- 最大天数 -->
				<el-form-item :label="$tt('label_pms_max_days')">
					<el-input-number v-model="weightForm.maxWeight" style="width: 140px;" :min="1" :max="36000" :label="$tt('label_pms_max_days')"></el-input-number>
				</el-form-item>

				<!-- 分段数量 -->
				<el-form-item :label="$tt('label_pms_split_nums')" v-if="weightForm.genType == 'byNumber'">
					<el-input-number v-model="weightForm.number" style="width: 140px;" :min="1" :max="100" :label="$tt('label_pms_split_nums')"></el-input-number>
				</el-form-item>

				<!-- 步长天数 -->
				<el-form-item :label="$tt('label_pms_step_days')" v-if="weightForm.genType == 'byStep'">
					<el-input v-model="weightForm.step" style="width: 100px;"></el-input>
				</el-form-item>

				<!-- 生成 -->
				<el-button @click="generateWeights">{{ $tt('label_pms_gernate') }}</el-button>

				<br />
				<!-- 时间段配置 -->
				<el-form-item :label="$tt('label_pms_time_period_cfg')" labelWidth="90px">
					<div style="width: 810px; display: flex; display: flex; flex-direction: row; flex-wrap: wrap;">
						<div v-for="(item, index) in weightArray" style="padding: 0px 6px 0px 6px; position: relative" @mouseover="item.showRemove = true" @mouseleave="item.showRemove = false">
							<input type="text" v-model="item.value" style="border: none; width: 40px; font-size: 14px; text-align: center; " />

							<i
								v-if="index > 0 && index < weightArray.length - 1"
								v-show="item.showRemove"
								@click="weightArray.splice(index, 1)"
								class="el-icon-remove"
								style="position: absolute; top: 0px; right: 0px; cursor: pointer; color: #d74343; "
							></i>
						</div>
					</div>
				</el-form-item>
			</el-form>
			<ex_header_spiler title="商品分类设置"></ex_header_spiler>
			<el-form>
				<!-- 商品分类设置 -->
				<el-checkbox v-if="formValue.openRent" v-model="formValue.openCustomSku">开启商品分类配置</el-checkbox>
				<el-row v-if="formValue.openCustomSku">
					<!-- 自定义商品规格-->
					<el-form-item label="自定义商品分类">
						<div style="text-align: right;">
							<!--添加 -->
							<el-button type="text" icon="el-icon-plus" @click="addCustomSkuSpec">{{ $tt('label_add') }}</el-button>
						</div>
						<el-table :data="formValue.customSkuSpecList" style="width: 100%;" border>
							<el-table-column prop="name" label="分类名称" min-width="100" align="center">
								<template slot-scope="scope">
									<el-input v-model="scope.row.name" style="width: 100%"></el-input>
								</template>
							</el-table-column>

							<el-table-column prop="startWeight" label="重量" min-width="100" align="center">
								<template slot-scope="scope">
									<div style="display: flex; padding: 0px 8px; justify-content: space-between; ">
										<el-input type="text" v-model="scope.row.startWeight" class="price-edit-inner-input" style="width: 44%;" />
										<span>~</span>
										<el-input type="text" v-model="scope.row.endWeight" class="price-edit-inner-input" style="width: 44%;" />
									</div>
								</template>
							</el-table-column>

							<el-table-column prop="startLength" label="长（cm）" min-width="100" align="center">
								<template slot-scope="scope">
									<div style="display: flex; padding: 0px 8px; justify-content: space-between; ">
										<el-input type="text" v-model="scope.row.startLength" class="price-edit-inner-input" style="width: 44%;" />
										<span>~</span>
										<el-input type="text" v-model="scope.row.endLength" class="price-edit-inner-input" style="width: 44%;" />
									</div>
								</template>
							</el-table-column>

							<el-table-column prop="startWidth" label="宽（cm）" min-width="100" align="center">
								<template slot-scope="scope">
									<div style="display: flex; padding: 0px 8px; justify-content: space-between; ">
										<el-input type="text" v-model="scope.row.startWidth" class="price-edit-inner-input" style="width: 44%;" />
										<span>~</span>
										<el-input type="text" v-model="scope.row.endWidth" class="price-edit-inner-input" style="width: 44%;" />
									</div>
								</template>
							</el-table-column>

							<el-table-column prop="endHeight" label="高（cm）" min-width="100" align="center">
								<template slot-scope="scope">
									<div style="display: flex; padding: 0px 8px; justify-content: space-between; ">
										<el-input type="text" v-model="scope.row.startHeight" class="price-edit-inner-input" style="width: 44%;" />
										<span>~</span>
										<el-input type="text" v-model="scope.row.endHeight" class="price-edit-inner-input" style="width: 44%;" />
									</div>
								</template>
							</el-table-column>

							<!-- 操作 -->
							<el-table-column prop="price" label="操作" min-width="100" align="center">
								<template slot-scope="scope">
									<!-- 删除 -->
									<el-button type="text" @click="formValue.customSkuSpecList.splice(scope.$index, 1)">
										{{ $tt('label_delete') }}
									</el-button>
								</template>
							</el-table-column>
						</el-table>
					</el-form-item>
				</el-row>

				<span v-if="formValue.openCustomSku" style="color: #666; line-height: 32px; margin-top: 10px;height: 40px; ">
					<i class="el-icon-warning" style="margin-right: 6px;"></i>区间命中规则： 起始 <= 匹配值 < 终止</span
				>
			</el-form>

			<div slot="footer" class="dialog-footer" style="display: flex; justify-content: space-between; ">
				<span style="color: orangered; padding-left: 96px;">
					<i class="el-icon-warning"></i>
					<!-- 重新调整时间段后，当前的仓租费用配置会清零 -->
					{{ $tt('label_pms_tenant_re_config_tip1') }}</span
				>
				<div>
					<!-- 取 消 -->
					<el-button @click="dialogFormVisible = false">{{ $tt('label_cancel') }}</el-button>
					<!-- 保 存 -->
					<el-button type="primary" @click="saveHouseRent">{{ $tt('label_submit') }}</el-button>
				</div>
			</div>
		</el-dialog>

		<!-- 旺季时间段配置 -->
		<!--    <el-dialog :title="$tt('label_pms_host_time_cfg')" :visible.sync="additionalVisible" width="700px">-->
		<!--      <el-form inline style="padding-left: 20px;">-->

		<!--        <div style="line-height: 40px;">-->
		<!--          &lt;!&ndash;添加 &ndash;&gt;-->
		<!--          <el-button icon="el-icon-plus" @click="additionalDateArr.push({})">{{$tt('label_add')}}</el-button>-->
		<!--        </div>-->

		<!--        <div v-for="(item,index) in additionalDateArr" style="display: flex; line-height: 40px;">-->

		<!--          <div style="margin-right: 10px;">-->
		<!--            &lt;!&ndash; 开始日期 &ndash;&gt;-->
		<!--            <el-date-picker v-model="item.date1" value-format="timestamp" type="date" :placeholder="$tt('label_pms_start_date')">-->
		<!--            </el-date-picker>-->
		<!--          </div>-->
		<!--          <div style="margin-right: 10px;">-->
		<!--            &lt;!&ndash; 结束日期 &ndash;&gt;-->
		<!--            <el-date-picker v-model="item.date2" value-format="timestamp" type="date" :placeholder="$tt('label_pms_end_date')">-->
		<!--            </el-date-picker>-->
		<!--          </div>-->
		<!--          <div>-->
		<!--            &lt;!&ndash; 删除 &ndash;&gt;-->
		<!--            <el-button @click="additionalDateArr.splice(index, 1)">{{ $tt('label_delete') }}</el-button>-->
		<!--          </div>-->
		<!--        </div>-->
		<!--      </el-form>-->

		<!--        <div slot="footer" class="dialog-footer" style=" margin-left: 150px; ">-->
		<!--          &lt;!&ndash; 取 消 &ndash;&gt;-->
		<!--          <el-button @click="additionalVisible = false">{{ $tt('label_cancel') }}</el-button>-->
		<!--          &lt;!&ndash; 保 存 &ndash;&gt;-->
		<!--          <el-button type="primary" @click="confirmWeight">{{ $tt('label_save') }}</el-button>-->
		<!--        </div>-->
		<!--      </el-dialog>-->

		<!-- 重量段配置 -->
		<el-dialog :title="$tt('label_pms_weight_range_cfg')" :visible.sync="weightRangeDialogFormVisible" width="1200px">
			<ex_header_spiler title="区间配置"></ex_header_spiler>
			<el-form inline>
				<!-- 生成方式 -->
				<el-form-item :label="$tt('label_pms_generate_type')" labelWidth="90px">
					<el-radio-group v-model="weightForm.genType">
						<!-- 按步长 -->
						<el-radio-button label="byStep">{{ $tt('label_pms_by_step') }}</el-radio-button>
						<!-- 按分段数量 -->
						<el-radio-button label="byNumber">{{ $tt('label_pms_by_split_num') }}</el-radio-button>
					</el-radio-group>
				</el-form-item>
				<!-- 最大体积 CBM': '最大重量 Kg -->
				<el-form-item :label="$tt('label_pms_max_weight') + 'Kg'">
					<el-input-number v-model="weightForm.maxWeight" style="width: 140px;" :min="1" :max="100000"></el-input-number>
				</el-form-item>
				<!-- 分段数量 -->
				<el-form-item :label="$tt('label_pms_split_nums')" v-if="weightForm.genType == 'byNumber'">
					<el-input-number v-model="weightForm.number" style="width: 140px;" :min="1" :max="100"></el-input-number>
				</el-form-item>
				<!-- 步长体积 CBM': '步长重量 Kg -->
				<el-form-item :label="$tt('label_pms_stop_weight') + ' Kg'" v-if="weightForm.genType == 'byStep'">
					<el-input v-model="weightForm.step" style="width: 100px;"></el-input>
				</el-form-item>

				<!-- 生成 -->
				<el-button @click="generateWeights">{{ $tt('label_pms_gernate') }}</el-button>

				<!-- 确认  -->
				<el-button @click="confirmRange">确认</el-button>

				<br />
				<!-- 体积段配置   重量段配置 -->
				<el-form-item :label="$tt('label_pms_weight_range_cfg')" labelWidth="90px">
					<div style="width: 810px; display: flex; display: flex; flex-direction: row; flex-wrap: wrap;">
						<div v-for="(item, index) in weightArray" style="padding: 0px 6px 0px 6px; position: relative" @mouseover="item.showRemove = true" @mouseleave="item.showRemove = false">
							<input type="text" v-model="item.value" style="border: none; width: 40px; font-size: 14px; text-align: center; " />
							<i
								v-if="index > 0 && index < weightArray.length - 1"
								v-show="item.showRemove"
								@click="weightArray.splice(index, 1)"
								class="el-icon-remove"
								style="position: absolute; top: 0px; right: 0px; cursor: pointer; color: #d74343;"
							></i>
						</div>
					</div>
				</el-form-item>
			</el-form>
			<ex_header_spiler title="价格配置"></ex_header_spiler>
			<el-form label-width="80px" class="common-form-panel-div" style="padding-left: 10px;">
				<el-form-item label="计价模式">
					<el-radio-group v-model="weightRangeFrom.priceType" style="padding-left: 10px;">
						<!-- 单价 -->
						<el-radio label="SINGLE">
							{{ $tt('PmsTransportPriceTypeEnum__SINGLE') }}
						</el-radio>
						<!-- 续重-->
						<el-radio label="ADD">
							{{ $tt('PmsTransportPriceTypeEnum__ADD') }}
						</el-radio>
						<!-- 总价 -->
						<el-radio label="TOTAL">
							{{ $tt('PmsTransportPriceTypeEnum__TOTAL') }}
						</el-radio>
						<!-- 首重+续重 -->
						<el-radio label="MULTI_ADD">
							{{ $tt('PmsTransportPriceTypeEnum__MULTI_ADD') }}
						</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="价格配置">
					<div class="flex_row" style="overflow: auto">
						<div v-for="(item, index) in weightRangeFrom.priceRanges" style="min-width: 150px;" class="flexuse">
							<div>
								<div class="flex_center">{{ getElLabel(item, index) }}</div>
								<div v-if="weightRangeFrom.priceType === 'MULTI_ADD'" style="display: flex; padding: 0px 8px; justify-content: space-around; ">
									<div style="text-align: center;">首重价</div>
									<div style="text-align: center;">续重价</div>
								</div>
							</div>
							<template v-if="weightRangeFrom.priceType !== 'MULTI_ADD'">
								<el-input type="text" v-model="item.price" class="price-edit-inner-input" style="width: 80%;" />
							</template>
							<template v-else-if="weightRangeFrom.priceType === 'MULTI_ADD'">
								<div style="display: flex; padding: 4px 8px; justify-content: space-between;">
									<el-input type="text" v-model="weightRangeFrom.priceRanges[index].startPrice" class="price-edit-inner-input" style="width: 44%;" />
									<el-input type="text" v-model="weightRangeFrom.priceRanges[index].addPrice" class="price-edit-inner-input" style="width: 44%;" />&nbsp;
								</div>
							</template>
						</div>
					</div>
				</el-form-item>
				<span style="color: #666; line-height: 32px; margin-top: 10px;height: 40px; "> <i class="el-icon-warning" style="margin-right: 6px;"></i>区间命中规则： 起始 <= 匹配值 < 终止</span>
			</el-form>

			<div slot="footer" class="dialog-footer" style=" margin-left: 150px; ">
				<div>
					<el-button @click="weightRangeDialogFormVisible = false">{{ $tt('label_cancel') }}</el-button>
					<el-button type="primary" @click="saveWeightRange">{{ $tt('label_save') }}</el-button>
				</div>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import FmsCurrencyChoose from '@/component/fms/fms-currency-choose.vue';
import WarehousePriceCfg from '@/component/pms/warehouse_price_cfg.vue';
import Vue from 'vue';
import ExpressionEditDialog from '@/component/fms/expression-edit-dialog.vue';

export default {
	name: 'warehouse_product_biz_price',
	components: { ExpressionEditDialog, WarehousePriceCfg, FmsCurrencyChoose },
	mixins: [],
	data() {
		return {
			randomId: Math.random(),
			// stand / additional
			updateWeightRangeType: 'stand',
			expressType: 'stand',

			uniqueHouseRentList: [],
			weightRangeDialogFormVisible: false,
			dialogFormVisible: false,
			additionalVisible: false,
			weightRangeFrom: {
				priceType: '',
				priceRanges: [],
			},
			additionalDateArr: [],
			formValue: {
				currencyType: 'CNY',
				costCurrency: 'CNY',
				timeZone: 'BEIJING',
				timePoint: '00:00:00',
				openRent: false,
				openCustomSku: false,
				openAdditional: false,
				minVolume: 0.5,
				outboundTimeOut: 48,
				customSkuSpecList: [],
				houseRentPrice: [],
				standardServicePrice: [],
				additionalServicePrice: [],
				heavyWeight: 30,
				tmpLocationPrice: 0,
			},
			weightForm: {
				genType: 'byNumber',
				maxWeight: 100,
				number: 20,
				step: 0.5,
			},

			weightArray: [
				{
					showRemove: false,
					value: 0,
				},
				{
					showRemove: false,
					value: 30,
				},
				{
					showRemove: false,
					value: 90,
				},
				{
					showRemove: false,
					value: 180,
				},
				{
					showRemove: false,
					value: 360,
				},
			],

			editWeightTableRows: [],
		};
	},
	props: {
		productGlobalConfig: {
			type: Object,
			default: () => {},
		},

		bizType: {
			type: String,
			default: '',
		},

		standardServices: {
			type: Array,
			default: () => [],
		},

		additionalServices: {
			type: Array,
			default: () => [],
		},

		priceUnitMap: {
			type: Object,
			default: () => {},
		},

		inputForm: {
			type: Object,
			default: () => {},
		},
	},
	created() {
		let _this = this;

		_this.initForm();
	},
	mounted() {},
	watch: {
		inputForm(newValue, oldValue) {
			this.initForm();
		},
		productGlobalConfig(newValue, oldValue) {
			this.productGlobalConfig = newValue;
		},
	},
	methods: {
		saveExpression(expressionForm) {
			let index = expressionForm.index;

			// console.log(expressionForm)

			if (this.expressType === 'stand') {
				this.$set(this.formValue.standardServicePrice[index], 'remark', expressionForm.remark);
				this.$set(this.formValue.standardServicePrice[index], 'expressionFunction', expressionForm.expressionFunction);
			} else {
				this.$set(this.formValue.additionalServicePrice[index], 'remark', expressionForm.remark);
				this.$set(this.formValue.additionalServicePrice[index], 'expressionFunction', expressionForm.expressionFunction);
			}

			// console.log(this.formValue.standardServicePrice[index])
		},

		showExpressionDialog(item, index, type) {
			this.expressType = type;
			this.$refs['expression'].showDialog(item, index);
		},

		getFormData() {
			this.formValue.standardServicePrice.forEach((e) => {
				if (e.chargeType === 'EXPRESSION' || e.chargeType === 'WEIGHT_RANGE') {
					e.maxPrice = -1;
				}
			});
			this.formValue.additionalServicePrice.forEach((e) => {
				if (e.chargeType === 'EXPRESSION' || e.chargeType === 'WEIGHT_RANGE') {
					e.maxPrice = -1;
				}
			});

			let tmp = JSON.parse(JSON.stringify(this.formValue));
			tmp.bizType = this.bizType;
			tmp.productGlobalConfig = this.productGlobalConfig;

			return tmp;
		},

		choosePriceType(list, row) {
			// * 订单维度  单、重量、体积、包裹数/箱数/板数、商品件数、重量段
			// * 包裹维度  包裹数/箱数/板数、商品件数、重量段
			// * 商品维度  商品件数、重量段
			let tmp = [];
			if (row.priceGranularity === 'ORDER') {
				tmp = list.filter((it) => it !== 'CAL_WEIGHT' && it !== 'PERCENT' && it !== 'DENSITY');
			} else if (row.priceGranularity === 'BOX') {
				tmp = ['PACKAGE', 'PCS', 'BOX', 'TRAY', 'WEIGHT_RANGE'];
			} else if (row.priceGranularity === 'SKU') {
				tmp = ['PCS', 'WEIGHT_RANGE'];
			}
			return tmp;
		},
		// 重置区间段，点击弹窗时触发
		resetWeightArray(type) {
			if (type === 'RENT') {
				if (this.formValue.houseRentPrice && this.formValue.houseRentPrice.length > 0) {
					let weightArray = [];
					this.uniqueHouseRentList = _.uniqBy(this.formValue.houseRentPrice, 'startDay');
					this.uniqueHouseRentList.forEach((e) => {
						weightArray.push({
							showRemove: false,
							value: e.startDay,
						});
					});
					this.weightArray = weightArray;
				}
				return;
			}
			if (type === 'WEIGHT_RANGE') {
				if (this.weightRangeFrom.priceRanges && this.weightRangeFrom.priceRanges.length > 0) {
					let weightArray = [];
					this.weightRangeFrom.priceRanges.forEach((e) => {
						weightArray.push({
							showRemove: false,
							value: e.start,
						});
					});
					this.weightArray = weightArray;
				}
			}
		},

		// 重新组合仓租
		rebuildHouseRent() {
			let houseRentPrice = this.formValue.houseRentPrice;
			this.uniqueHouseRentList = _.uniqBy(houseRentPrice, 'startDay');

			let customSkuSpecList = [];
			if (this.formValue.openCustomSku) {
				customSkuSpecList = this.formValue.customSkuSpecList;
			}

			let tmp = [];
			this.uniqueHouseRentList.forEach((e) => {
				if (customSkuSpecList.length === 0) {
					let tmpRow = JSON.parse(JSON.stringify(e));
					tmpRow.customSkuSpecIndex = 0;
					tmpRow.customSkuSpecName = '-';
					tmp.push(tmpRow);
				} else {
					for (let i = 0; i < customSkuSpecList.length; i++) {
						let tmpRow = JSON.parse(JSON.stringify(e));
						tmpRow.customSkuSpecIndex = customSkuSpecList[i].index;
						tmpRow.customSkuSpecName = customSkuSpecList[i].name;
						tmp.push(tmpRow);
					}
				}
			});
			this.formValue.houseRentPrice = tmp;
		},
		confirmRange() {
			let editWeightTableHead = [];

			let samplePricePeriod = [];

			if (this.weightRangeFrom.priceType === 'MULTI_ADD' && this.weightArray.length <= 2) {
				this.$message({
					type: 'error',
					message: '首重+续重计价模式分段数量必须大于1',
				});
				return;
			}
			for (let i = 0; i < this.weightArray.length; i++) {
				let e = this.weightArray[i].value;

				let isNum = this.$isNumber(e);

				if (!isNum) {
					this.$message({
						type: 'error',
						message: e + ' is not a number',
					});

					return;
				}

				if (i == 0) {
					continue;
				}

				if (parseFloat(this.weightArray[i].value) <= parseFloat(this.weightArray[i - 1].value)) {
					this.$message({
						type: 'error',
						message: '数据必须从小到大排列',
					});
					return;
				}

				editWeightTableHead.push({
					id: 'id_' + Math.random(),
					value: this.weightArray[i - 1].value + '-' + this.weightArray[i].value,
				});

				samplePricePeriod.push({
					start: this.weightArray[i - 1].value,
					end: this.weightArray[i].value,
					price: 10,
					startPrice: 10,
					addPrice: 10,
					unit: 'kg',
				});
			}

			this.samplePricePeriod = samplePricePeriod;

			// 首重值
			// this.firstWeightValue = this.weightArray[1].value

			this.editWeightTableHead = editWeightTableHead;

			let tmp = [].concat(JSON.parse(JSON.stringify(samplePricePeriod)));
			this.weightRangeFrom.priceRanges = tmp;
			this.$set(this, 'weightRangeFrom', _.clone(this.weightRangeFrom));
		},

		showPriceUnitDesc(currencyCode, unit, chargeType) {
			if (chargeType === 'WEIGHT' && unit) {
				var replace = unit.toLowerCase().replace('kg', this.productGlobalConfig.weightUnit);
				unit = replace;
			}

			if (!unit) {
				if (currencyCode == 'CNY') {
					return '元';
				}
				return this.$tt('CurrencyTypeEnum__' + currencyCode);
			}

			if (currencyCode == 'CNY') {
				return unit;
			}

			let tmp = unit.indexOf('元');
			if (tmp == -1) {
				return unit;
			}

			let unitDesc = this.$tt('CurrencyTypeEnum__' + currencyCode);

			return unitDesc + unit.substring(1);
		},

		initForm() {
			let inputForm = {};

			inputForm = _.cloneDeep(this.inputForm);

			this.productGlobalConfig = this.productGlobalConfig;

			if (!inputForm.standardServicePrice) {
				inputForm.standardServicePrice = [];
			}
			if (!inputForm.additionalServicePrice) {
				inputForm.additionalServicePrice = [];
			}

			// 标准费用项
			let standardServices = _.cloneDeep(this.standardServices);
			if (inputForm.standardServicePrice.length == 0) {
				inputForm.standardServicePrice = standardServices;
			} else {
				standardServices.forEach((row) => {
					inputForm.standardServicePrice.forEach((formRow) => {
						if (row.serviceCode == formRow.serviceCode) {
							formRow.showMax = row.showMax;
							row.priceGranularity = formRow.priceGranularity;
							row.rangeMatchMode = formRow.rangeMatchMode;
							row.priceRanges = formRow.priceRanges;
							row.priceType = formRow.priceType;
							row.remark = formRow.remark;
							row.expressionFunction = formRow.expressionFunction;
							for (let kk in row) {
								row[kk] = formRow[kk];
							}
						}
					});
				});

				inputForm.standardServicePrice = standardServices;
			}
			if (!_.isEmpty(this.formValue.standardServicePrice)) {
				for (let i = 0; i < inputForm.standardServicePrice.length; i++) {
					const item = inputForm.standardServicePrice[i];
					const t = _.findIndex(this.formValue.standardServicePrice, (it) => it.serviceCode == item.serviceCode);
					if (t >= 0) {
						inputForm.standardServicePrice.splice(i, 1, this.formValue.standardServicePrice[t]);
					}
				}
			}
			// 附加服务费用项
			let additionalServices = _.cloneDeep(this.additionalServices);
			if (inputForm.additionalServicePrice.length == 0) {
				inputForm.additionalServicePrice = additionalServices;
			} else {
				additionalServices.forEach((row) => {
					inputForm.additionalServicePrice.forEach((formRow) => {
						if (row.serviceCode == formRow.serviceCode) {
							formRow.showMax = row.showMax;
							row.priceGranularity = formRow.priceGranularity;
							row.rangeMatchMode = formRow.rangeMatchMode;
							row.priceRanges = formRow.priceRanges;
							row.priceType = formRow.priceType;
							row.remark = formRow.remark;
							row.expressionFunction = formRow.expressionFunction;
							for (let kk in row) {
								row[kk] = formRow[kk];
							}
						}
					});
				});

				inputForm.additionalServicePrice = additionalServices;
			}
      if (!_.isEmpty(this.formValue.additionalServicePrice)) {
				for (let i = 0; i < inputForm.additionalServicePrice.length; i++) {
					const item = inputForm.additionalServicePrice[i];
					const t = _.findIndex(this.formValue.additionalServicePrice, (it) => it.serviceCode == item.serviceCode);
					if (t >= 0) {
						inputForm.additionalServicePrice.splice(i, 1, this.formValue.additionalServicePrice[t]);
					}
				}
			}
			// 仓租处理
			if (!inputForm.houseRentPrice) {
				inputForm.houseRentPrice = [];
			}
			if (inputForm.houseRentPrice && inputForm.houseRentPrice.length > 0) {
				let weightArray = [];
				for (let i = 0; i < inputForm.houseRentPrice.length; i++) {
					let rentRow = inputForm.houseRentPrice[i];
					rentRow.period = rentRow.startDay + '-' + rentRow.endDay;

					if (rentRow.endDay == -1) {
						rentRow.period = '>' + rentRow.startDay;
					}
					rentRow.unit = '元/立方米/天';
				}

				this.uniqueHouseRentList = _.uniqBy(inputForm.houseRentPrice, 'startDay');
				this.uniqueHouseRentList.forEach((e) => {
					weightArray.push({
						showRemove: false,
						value: e.startDay,
					});
				});
				this.weightArray = weightArray;
			}

			for (let kk in inputForm) {
				this.formValue[kk] = inputForm[kk];
			}
		},
		generateWeights() {
			let weightForm = this.weightForm;
			let step = parseFloat(weightForm.step);

			if (weightForm.genType == 'byNumber') {
				step = parseFloat(weightForm.maxWeight) / parseFloat(weightForm.number);
			}
			let max = parseInt(weightForm.maxWeight);
			let arr = [];
			let start = 0;
			while (true) {
				if (start >= max) {
					arr.push({
						showRemove: false,
						value: max,
					});
					break;
				}
				arr.push({
					showRemove: false,
					value: start,
				});
				start += step;
				start = parseFloat(start.toFixed(3));
			}
			this.weightArray = arr;
		},
		saveHouseRent() {
			let editWeightTableRows = [];

			if (this.weightArray[this.weightArray.length - 1].value == -1) {
				this.weightArray.splice(this.weightArray.length - 1, 1);
			}

			for (let i = 0; i < this.weightArray.length; i++) {
				let e = this.weightArray[i].value;

				let isNum = this.$isNumber(e);

				if (!isNum) {
					this.$message({
						type: 'error',
						message: e + '不是数字',
					});
					return;
				}

				if (i == 0) {
					continue;
				}

				let tableHead = this.weightArray[i - 1].value + '-' + this.weightArray[i].value;

				let left = parseInt(this.weightArray[i - 1].value);
				let right = parseInt(this.weightArray[i].value);

				editWeightTableRows.push({
					startDay: left,
					endDay: right,
					period: left + '-' + right,
					price: 100,
					unit: '元/立方米/天',
					minPrice: 0,
					additionalPrice: 0,
				});

				if (i == this.weightArray.length - 1) {
					editWeightTableRows.push({
						startDay: right,
						endDay: -1,
						period: '>' + right,
						price: 100,
						unit: '元/立方米/天',
						minPrice: 0,
						additionalPrice: 0,
					});
				}
			}

			this.formValue.houseRentPrice = editWeightTableRows;

			let isbreak = false;

			if (this.formValue.openCustomSku) {
				if (!this.formValue.customSkuSpecList || this.formValue.customSkuSpecList.length == 0) {
					this.$message({
						type: 'error',
						message: '自定义商品分类不能为空',
					});
					return;
				}

				this.formValue.customSkuSpecList.forEach((e) => {
					if (
						_.isEmpty(e.name) ||
						_.isEmpty(e.startWeight) ||
						_.isEmpty(e.endWeight) ||
						_.isEmpty(e.startLength) ||
						_.isEmpty(e.endLength) ||
						_.isEmpty(e.startWidth) ||
						_.isEmpty(e.endWidth) ||
						_.isEmpty(e.startHeight) ||
						_.isEmpty(e.endHeight)
					) {
						this.$message({
							type: 'error',
							message: '自定义分类数据异常',
						});
						isbreak = true;
						return;
					}
					// 全部转换为 数字类型
					e.startWeight = parseFloat(e.startWeight);
					e.endWeight = parseFloat(e.endWeight);
					e.startLength = parseFloat(e.startLength);
					e.endLength = parseFloat(e.endLength);
					e.startWidth = parseFloat(e.startWidth);
					e.endWidth = parseFloat(e.endWidth);
					e.startHeight = parseFloat(e.startHeight);
					e.endHeight = parseFloat(e.endHeight);
				});

				for (let j = 0; j < this.formValue.customSkuSpecList.length; j++) {
					var pmsCustomSkuSpec = this.formValue.customSkuSpecList[j];

					if (j === 0) {
						if (pmsCustomSkuSpec.startWeight != 0 || pmsCustomSkuSpec.startLength != 0 || pmsCustomSkuSpec.startWidth != 0 || pmsCustomSkuSpec.startHeight != 0) {
							this.$message({
								type: 'error',
								message: '自定义分类数据异常，第一区间开始值必须为0',
							});
							isbreak = true;
							return;
						}
					}
					if (j !== 0) {
						var pre = this.formValue.customSkuSpecList[j - 1];
						if (
							pre.endWeight !== pmsCustomSkuSpec.startWeight ||
							pre.endLength !== pmsCustomSkuSpec.startLength ||
							pre.endWidth !== pmsCustomSkuSpec.startWidth ||
							pre.endHeight !== pmsCustomSkuSpec.startHeight
						) {
							this.$message({
								type: 'error',
								message: '自定义分类数据异常，区间不连续，上一区间结束值必须等于下一区间开始值',
							});
							isbreak = true;
							return;
						}
					}

					// 重定义索引
					pmsCustomSkuSpec.index = j;
					this.formValue.customSkuSpecList[j] = pmsCustomSkuSpec;
				}

				if (isbreak) {
					return;
				}
			}

			this.rebuildHouseRent();

			this.dialogFormVisible = false;
		},

		addCustomSkuSpec() {
			let e = {
				name: '',
				startWeight: '',
				endWeight: '',
				startLength: '',
				endLength: '',
				startWidth: '',
				endWidth: '',
				startHeight: '',
				endHeight: '',
			};
			this.formValue.customSkuSpecList.push(e);
		},

		weightRangeShow(row, index, type) {
			console.log(row);

			this.weightRangeFrom = JSON.parse(JSON.stringify(row));

			console.log(this.weightRangeFrom);

			this.weightRangeFrom.index = index;

			if (_.isEmpty(this.weightRangeFrom.priceRanges)) {
				this.weightRangeFrom.priceRanges = [];
			}
			if (_.isEmpty(this.weightRangeFrom.priceType)) {
				this.$set(this.weightRangeFrom, 'priceType', 'SINGLE');
			}

			this.weightRangeDialogFormVisible = true;
			this.updateWeightRangeType = type;
		},
		saveWeightRange() {
			// 校验数据
			if (this.weightRangeFrom && this.weightRangeFrom.priceRanges.length > 0) {
				for (let i = 0; i < this.weightRangeFrom.priceRanges.length; i++) {
					var e = this.weightRangeFrom.priceRanges[i];

					let price = e.price;
					if (!this.$isNumber(price)) {
						this.$message({
							type: 'error',
							message: price + ' is not a number',
						});
						return;
					}

					let start = e.start;
					if (!this.$isNumber(start)) {
						this.$message({
							type: 'error',
							message: 'start' + ' is not a number or null',
						});
						return;
					}

					let end = e.end;
					if (!this.$isNumber(end)) {
						this.$message({
							type: 'error',
							message: 'end' + ' is not a number or null',
						});
						return;
					}

					if (i == 0) {
						continue;
					}

					if (
						parseFloat(this.weightRangeFrom.priceRanges[i].start) < parseFloat(this.weightRangeFrom.priceRanges[i - 1].end) ||
						parseFloat(this.weightRangeFrom.priceRanges[i].start) != parseFloat(this.weightRangeFrom.priceRanges[i - 1].end)
					) {
						this.$message({
							type: 'error',
							message: '区间段数据必须连续，且必须从小到大排列，前一个区间结束值必须等于下一个区间起始值',
						});
						return;
					}
				}
			}

			if (this.updateWeightRangeType === 'stand') {
				Vue.set(this.formValue.standardServicePrice, this.weightRangeFrom.index, this.weightRangeFrom);
			} else {
				Vue.set(this.formValue.additionalServicePrice, this.weightRangeFrom.index, this.weightRangeFrom);
			}

			this.weightRangeDialogFormVisible = false;
		},

		getElLabel(item, index) {
			item.value = item.start + '-' + item.end;

			let weightUnit = this.productGlobalConfig.weightUnit;

			let unit = weightUnit;

			// 续重 - 首重价
			if (index == 0 && this.weightRangeFrom.priceType == 'ADD') {
				let tmps = item.value.split('-');
				return `${tmps[1]}${unit} ` + this.$tt('label_pms_under_price');
			}
			// 总价
			else if (this.weightRangeFrom.priceType == 'TOTAL') {
				return `${item.value}${unit} ` + this.$tt('label_pms_total_price');
			}
			// 续重 - 续重价
			else if (this.weightRangeFrom.priceType == 'ADD') {
				return `${item.value}${unit} ` + this.$tt('label_pms_added_price');
			}
			// 首重 + 续重
			else if (this.weightRangeFrom.priceType == 'MULTI_ADD') {
				return `${item.value}${unit}`;
			} else if (this.weightRangeFrom.priceType == 'SINGLE') {
				return `${item.value}${unit}`;
			}

			return item.value;
		},
	},
};
</script>

<style lang="less">
.flexuse {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding-bottom: 10px;
	border: 1px solid #d9dfe7;
	border-right: none;

	&:last-of-type {
		border-right: 1px solid rgb(217, 223, 231);
	}
}
</style>
